<?php


require 'database.php';


$___pided___=file_get_contents("../pid.txt");
$___pided___=explode(PHP_EOL,$___pided___);

$__demo__=file_get_contents("demo.json");
$__demo__=json_decode($__demo__,1);

if(!$___pided___){
    return ;
}
$___pid___=$___pided___[$__demo__["pid"]];
if($___pid___=="大"){
    $___pid___=1;
}elseif($___pid___=="小"){
    $___pid___=2;
}elseif($___pid___=="单"){
    $___pid___=3;
}elseif($___pid___=="双"){
    $___pid___=4;
}elseif($___pid___=="龙"){
    $___pid___=5;
}elseif($___pid___=="虎"){
    $___pid___=6;
}else{
    $___pid___=0;
}
//累加pid
if($__demo__["pid"] < $__demo__["pidend"]){
    $__demo__["pid"]=$__demo__["pid"]+1;
}else{
    $__demo__["pid"]=0;//归零
}



$__demo__=json_encode($__demo__,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
file_put_contents("demo.json",$__demo__);


return json([
    "pid"=>    $___pid___
]);

